package net.melon.sysres.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import net.esj.basic.annotation.IgnorePrint;
import net.esj.basic.pojo.AbstractPojo;
import net.esj.basic.pojo.EnumStructure;
import net.esj.basic.pojo.TreeStructure;

/**
 * 数据字典
 * @author HaoJB
 *
 */
public class Resource extends AbstractPojo<String> implements TreeStructure,EnumStructure {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String id;
	private String name;
	
	/**
	 * 资源大类
	 */
	private String keyType;
	
	/**
	 * 资源编号，父类编号*0xFF + 最大兄弟编号+1
	 * 一般用于查询时使用，通过编号只需 >父类编号*0xFF && <父类编号*0xFF+256 即可
	 */
	private int keyCode;
	private String keyValue;
	private String comments;
	private int parentCode;
	private Date gmtCreate;
	private Date gmtModify;
	private String creater;
	private String modifier;
	private boolean cascading;
	private int ordinal;
	private int priority;
	private boolean hasLeaf;
	
	private Resource parent;
	private Set<Resource> children =new HashSet<Resource>(0);
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getKeyType() {
		return keyType;
	}
	public void setKeyType(String keyType) {
		this.keyType = keyType;
	}
	public int getKeyCode() {
		return keyCode;
	}
	public void setKeyCode(int keyCode) {
		this.keyCode = keyCode;
	}
	public String getKeyValue() {
		return keyValue;
	}
	public void setKeyValue(String keyValue) {
		this.keyValue = keyValue;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public int getParentCode() {
		return parentCode;
	}
	public void setParentCode(int parentCode) {
		this.parentCode = parentCode;
	}
	public Date getGmtCreate() {
		return gmtCreate;
	}
	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}
	public Date getGmtModify() {
		return gmtModify;
	}
	public void setGmtModify(Date gmtModify) {
		this.gmtModify = gmtModify;
	}
	public String getCreater() {
		return creater;
	}
	public void setCreater(String creater) {
		this.creater = creater;
	}
	public String getModifier() {
		return modifier;
	}
	public void setModifier(String modifier) {
		this.modifier = modifier;
	}
	
	public boolean isCascading() {
		return cascading;
	}
	public void setCascading(boolean cascading) {
		this.cascading = cascading;
	}
	public Resource getParent() {
		return parent;
	}
	public void setParent(Resource parent) {
		this.parent = parent;
	}
	
	@IgnorePrint
	public Set<Resource> getChildren() {
		return children;
	}
	public void setChildren(Set<Resource> children) {
		this.children = children;
	}
	
	public int getOrdinal() {
		return ordinal;
	}
	public void setOrdinal(int ordinal) {
		this.ordinal = ordinal;
	}
	
	@Override
	public Resource getParentNode() {
		return parent;
	}
	
	@Override
	public String getNodeTitle() {
		return name;
	}
	@Override
	public String getNodeClsIcon() {
		return null;
	}
	@Override
	public Integer getNodeLoadType() {
		return TREE_LOAD_TYPE_ON_CLICK_PARENT;
	}
	@Override
	public Boolean hasCheckBox() {
		return false;
	}
	@Override
	public Boolean hasChildNode() {
		return getChildren()!=null && !getChildren().isEmpty() ;
	}
	@Override
	public Boolean isSelectCascade() {
		return false;
	}
	@Override
	public Boolean isNodeExpansion() {
		return false;
	}
	@Override
	public Collection<Resource> getChildNodes() {
		return getChildren();
	}
	@Override
	public Integer getEnumCode() {
		return keyCode;
	}
	@Override
	public Integer getEnumOrdinal() {
		return ordinal;
	}
	@Override
	public String getEnumTitle() {
		return name;
	}
	@Override
	public String getEnumType() {
		return keyType;
	}
	@Override
	public String getEnumValue() {
		return keyValue;
	}
	@Override
	public Serializable getNodeId() {
		return getId();
	}
	public int getPriority() {
		return priority;
	}
	public void setPriority(int priority) {
		this.priority = priority;
	}
	public boolean isHasLeaf() {
		return hasLeaf;
	}
	public void setHasLeaf(boolean hasLeaf) {
		this.hasLeaf = hasLeaf;
	}
}
